package com.qf.six.ssm.controller.product;


import com.qf.six.ssm.commen.request.CommodityParam;
import com.qf.six.ssm.commen.vo.ResponseResult;
import com.qf.six.ssm.entity.Commodity;
import com.qf.six.ssm.service.product.CommodityService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author ZL
 */
@RestController
@RequestMapping("/commodity")
public class CommodityController {
    @Resource
    CommodityService commodityService;
    @GetMapping("/selectById")
    public ResponseResult<Commodity> selectById(String id){
        //返回控制层
        return ResponseResult.success(commodityService.selectCo(id));
    }

    @GetMapping("/info")
    public ResponseResult<List<Commodity>> selectAll(){
        return ResponseResult.success(commodityService.select());
    }

    @GetMapping("/update")
    public ResponseResult<Commodity> update(Commodity commodity){
        return ResponseResult.success(commodityService.update(commodity));
    }

    @GetMapping("/insert")
    public ResponseResult<Integer> insert(CommodityParam param){
        return ResponseResult.success(commodityService.insert(param));
    }

    @GetMapping("del")
    public ResponseResult<Integer> delete(String cid){
        return ResponseResult.success(commodityService.del(cid));
    }
}
